import { Column, Entity, Index } from "typeorm";
import { BaseEntity } from "../../base/entity/base";

/**
 * 订单子项（行程/商品项）
 */
@Entity('order_item', { comment: '订单子项' })
export class OrderItemEntity extends BaseEntity {
    @Index()
    @Column({ comment: '订单ID' })
    orderId: number;

    @Index()
    @Column({ comment: '产品ID', nullable: true })
    productId: number;

    @Index()
    @Column({ comment: '产品项ID(对应SKU)', nullable: true })
    productItemId: number;

    @Column({ comment: '标题(自行下单或展示名称)', length: 255 })
    title: string;

    @Column({ comment: '单价', type: 'decimal', precision: 10, scale: 2 })
    unitPrice: number;

    @Column({ comment: '数量', default: 1 })
    quantity: number;

    @Column({ comment: '小计金额', type: 'decimal', precision: 12, scale: 2 })
    amount: number;

    @Column({ comment: '使用时间(或日期)', type: 'varchar', length: 50, nullable: true })
    useTime: string;

    @Column({ comment: '出发地', length: 255, nullable: true })
    startPlace: string;

    @Column({ comment: '目的地', length: 255, nullable: true })
    endPlace: string;

    @Column({ comment: '附加信息(按产品类型存差异字段)', type: 'json', nullable: true })
    extra: any;

    @Column({
        comment: '履约状态 0-待分配 1-待执行 2-执行中 3-待确认 4-已完成 5-已取消',
        dict: ['待分配', '待执行', '执行中', '待确认', '已完成', '已取消'],
        default: 0,
    })
    fulfillStatus: number;

    @Column({ comment: '履约状态更新时间', type: 'varchar', length: 30, nullable: true })
    fulfillStatusTime: string;
}


